CREATE PROCEDURE ObtenerProyectosxPais
	-- Add the parameters for the stored procedure here
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT P.Id, P.Nombre, Sf.CodigoSolicitud FROM Pais AS P INNER JOIN
	(SELECT Sf.Proyecto, Sf.CodigoSolicitud, Ps.Pais FROM SolicitudFinanciamiento Sf INNER JOIN
	PaisesxSolicitud as Ps
	ON Ps.Pais = Sf.Id) as Sf
	ON P.Id = Sf.Proyecto
	WHERE  @Id = Sf.CodigoSolicitud
END
GO
